package com.SpringBoot;

import com.alibaba.nacos.api.config.ConfigType;
import com.alibaba.nacos.api.config.annotation.NacosConfigListener;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@NacosPropertySource(dataId = "erp-${spring.profiles.active}.yml",groupId = "myProject", autoRefreshed = true, type = ConfigType.YAML)
@SpringBootApplication
@MapperScan("com.SpringBoot.mapper")
public class SpringBootErpApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootErpApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

        return builder.sources(SpringBootErpApplication.class);

    }
    /**
     * 监听Nacos加载
     *
     * @param config
     */
    @NacosConfigListener(dataId = "IAM", type = ConfigType.YAML)
    public void onMessage(String config) {
        System.out.println(config);
    }
}
